<template>
  <div class="examlist_container">
    <div class="title">
      <h2> 法治思维 快乐学法</h2>
    </div>
    <div class="typeSelect">
      <h3>
        {{examInfo.theme}}
      </h3>
    </div>

    <div class="examlist">
      <div class="examInfo">

        <span class="tips">考试须知</span>

        <div class="detalis">
          {{examInfo.introduce}}
        </div>

      </div>

    </div>

    <div class="step step_3">
      <van-button round type="info" @click="recordList()">考试记录</van-button>
      <van-button round type="info" @click="toExam" class="middleBtn">开始考试</van-button>
      <van-button round type="info" @click="topList()">排行榜</van-button>
    </div>
  </div>
</template>
<style scoped>
</style>
<script>
import path from '@/network'
export default {
  name: 'App',

  data () {
    return {
      examInfo: JSON.parse(sessionStorage.getItem('examInfo')),
      examId: this.$route.query.id

    };
  },

  created () {
  },
  beforeDestroy () {
  },

  mounted () {




  },
  methods: {

    toExam: function () {
      this.beginExam()
    },

    //获取list
    beginExam () {
      path.beginExam({
        examId: this.$route.query.id
      }).then(res => {
        if (res.success === 0) {

          //console.log(JSON.stringify(res))
          //var res = { "data": { "checkCount": 2, "checkPoint": 2, "checkQuestions": [{ "answers": [{ "content": "对", "correct": 1, "correct_content": "", "id": 83 }, { "content": "错", "correct": 2, "correct_content": "", "id": 84 }], "content": "同一个违法行为，不得给予两次以上罚款的行政处罚。（）", "correctCount": 1, "explains": "", "id": 22 }, { "answers": [{ "content": "对", "correct": 2, "correct_content": "", "id": 93 }, { "content": "错", "correct": 1, "correct_content": "", "id": 94 }], "content": "依据《中华人民共和国行政处罚法》的规定行使相对集中行政处罚权的行政机关，不可以实施法律、法规规定的与行政处罚权有关的行政强制措施。（）", "correctCount": 1, "explains": "", "id": 27 }], "checkTotalPoint": 4, "completionCount": 0, "completionPoint": 0, "completionQuestions": [], "completionTotalPoint": 0, "examId": 2, "multipleCount": 2, "multiplePoint": 2, "multipleQuestions": [{ "answers": [{ "content": "A. 政治意义", "correct": 1, "correct_content": "", "id": 173 }, { "content": "B. 理论意义", "correct": 1, "correct_content": "", "id": 174 }, { "content": "C. 实践意义", "correct": 1, "correct_content": "", "id": 175 }, { "content": "D. 世界意义", "correct": 2, "correct_content": "", "id": 176 }], "content": "习近平总书记创造性提出了关于全面依法治国的一系列新理念新思想新战略，形成了内涵丰富、科学系统的思想体系，为建设法治中国指明了前进方向，在中国特色社会主义法治建设进程中具有重大（ ）。", "correctCount": 3, "explains": "", "id": 49 }, { "answers": [{ "content": "A. 揭发", "correct": 2, "correct_content": "", "id": 41 }, { "content": "B. 申诉", "correct": 1, "correct_content": "", "id": 42 }, { "content": "C. 检举", "correct": 1, "correct_content": "", "id": 43 }, { "content": "D. 控告", "correct": 2, "correct_content": "", "id": 44 }], "content": "新修订的《行政处罚法》规定：公民法人或者其他组织对行政机关实施行政处罚的行为，有权（）。", "correctCount": 2, "explains": "", "id": 11 }], "multipleTotalPoint": 4, "qualifiedPoint": 2, "singleCount": 2, "singlePoint": 2, "singleQuestions": [{ "answers": [{ "content": "A. 公安机关 ", "correct": 1, "correct_content": "", "id": 225 }, { "content": "B. 人民检察院 ", "correct": 2, "correct_content": "", "id": 226 }, { "content": "C. 人民法院 ", "correct": 2, "correct_content": "", "id": 227 }, { "content": "D. 监狱管理局", "correct": 2, "correct_content": "", "id": 228 }], "content": "国务院或者经国务院授权的省、自治区、直辖市人民政府能够决定一个行政机关行使有关行政机关的行政处罚权，但限制人身自由的行政处罚权只能由(    )行使。", "correctCount": 1, "explains": "", "id": 67 }, { "answers": [{ "content": "A. 一", "correct": 2, "correct_content": "", "id": 13 }, { "content": "B. 二", "correct": 1, "correct_content": "", "id": 14 }, { "content": "C. 三", "correct": 2, "correct_content": "", "id": 15 }, { "content": "D. 四", "correct": 2, "correct_content": "", "id": 16 }], "content": "行政处罚应当由具有行政执法资格的执法人员实施。执法人员不得少于两人，法律另有规定的除外。", "correctCount": 1, "explains": "", "id": 4 }], "singleTotalPoint": 4, "totalPoint": 12, "unsurenessCount": 0, "unsurenessPoint": 0, "unsurenessQuestions": [], "unsurenessTotalPoint": 0 }, "errors": [], "msg": "", "page": 1, "pageSize": 1, "rows": { "checkCount": 2, "checkPoint": 2, "checkQuestions": [{ "answers": [{ "content": "对", "correct": 1, "correct_content": "", "id": 83 }, { "content": "错", "correct": 2, "correct_content": "", "id": 84 }], "content": "同一个违法行为，不得给予两次以上罚款的行政处罚。（）", "correctCount": 1, "explains": "", "id": 22 }, { "answers": [{ "content": "对", "correct": 2, "correct_content": "", "id": 93 }, { "content": "错", "correct": 1, "correct_content": "", "id": 94 }], "content": "依据《中华人民共和国行政处罚法》的规定行使相对集中行政处罚权的行政机关，不可以实施法律、法规规定的与行政处罚权有关的行政强制措施。（）", "correctCount": 1, "explains": "", "id": 27 }], "checkTotalPoint": 4, "completionCount": 0, "completionPoint": 0, "completionQuestions": [], "completionTotalPoint": 0, "examId": 2, "multipleCount": 2, "multiplePoint": 2, "multipleQuestions": [{ "answers": [{ "content": "A. 政治意义", "correct": 1, "correct_content": "", "id": 173 }, { "content": "B. 理论意义", "correct": 1, "correct_content": "", "id": 174 }, { "content": "C. 实践意义", "correct": 1, "correct_content": "", "id": 175 }, { "content": "D. 世界意义", "correct": 2, "correct_content": "", "id": 176 }], "content": "习近平总书记创造性提出了关于全面依法治国的一系列新理念新思想新战略，形成了内涵丰富、科学系统的思想体系，为建设法治中国指明了前进方向，在中国特色社会主义法治建设进程中具有重大（ ）。", "correctCount": 3, "explains": "", "id": 49 }, { "answers": [{ "content": "A. 揭发", "correct": 2, "correct_content": "", "id": 41 }, { "content": "B. 申诉", "correct": 1, "correct_content": "", "id": 42 }, { "content": "C. 检举", "correct": 1, "correct_content": "", "id": 43 }, { "content": "D. 控告", "correct": 2, "correct_content": "", "id": 44 }], "content": "新修订的《行政处罚法》规定：公民法人或者其他组织对行政机关实施行政处罚的行为，有权（）。", "correctCount": 2, "explains": "", "id": 11 }], "multipleTotalPoint": 4, "qualifiedPoint": 2, "singleCount": 2, "singlePoint": 2, "singleQuestions": [{ "answers": [{ "content": "A. 公安机关 ", "correct": 1, "correct_content": "", "id": 225 }, { "content": "B. 人民检察院 ", "correct": 2, "correct_content": "", "id": 226 }, { "content": "C. 人民法院 ", "correct": 2, "correct_content": "", "id": 227 }, { "content": "D. 监狱管理局", "correct": 2, "correct_content": "", "id": 228 }], "content": "国务院或者经国务院授权的省、自治区、直辖市人民政府能够决定一个行政机关行使有关行政机关的行政处罚权，但限制人身自由的行政处罚权只能由(    )行使。", "correctCount": 1, "explains": "", "id": 67 }, { "answers": [{ "content": "A. 一", "correct": 2, "correct_content": "", "id": 13 }, { "content": "B. 二", "correct": 1, "correct_content": "", "id": 14 }, { "content": "C. 三", "correct": 2, "correct_content": "", "id": 15 }, { "content": "D. 四", "correct": 2, "correct_content": "", "id": 16 }], "content": "行政处罚应当由具有行政执法资格的执法人员实施。执法人员不得少于两人，法律另有规定的除外。", "correctCount": 1, "explains": "", "id": 4 }], "singleTotalPoint": 4, "totalPoint": 12, "unsurenessCount": 0, "unsurenessPoint": 0, "unsurenessQuestions": [], "unsurenessTotalPoint": 0 }, "stCode": "0", "success": 0, "timestamp": "1639043361798", "total": 0, "totalPage": 0 }

          if (res.rows != null) {
            if (res.rows.unsurenessQuestions != null && res.rows.unsurenessQuestions.length > 0) {
              sessionStorage.setItem("unsurenessQuestions", JSON.stringify(res.rows.unsurenessQuestions))

            }
            if (res.rows.singleQuestions != null && res.rows.singleQuestions.length > 0) {
              sessionStorage.setItem("singleQuestions", JSON.stringify(res.rows.singleQuestions))

            }
            if (res.rows.multipleQuestions != null && res.rows.multipleQuestions.length > 0) {
              sessionStorage.setItem("multipleQuestions", JSON.stringify(res.rows.multipleQuestions))
            }
            if (res.rows.checkQuestions != null && res.rows.checkQuestions.length > 0) {
              sessionStorage.setItem("checkQuestions", JSON.stringify(res.rows.checkQuestions))
            }
            if (res.rows.completionQuestions != null && res.rows.completionQuestions.length > 0) {
              sessionStorage.setItem("completionQuestions", JSON.stringify(res.rows.completionQuestions))
            }


            let examPaper = {
              checkCount: res.rows.checkCount,
              checkPoint: res.rows.checkPoint,
              checkTotalPoint: res.rows.checkTotalPoint,

              completionCount: res.rows.completionCount,
              completionPoint: res.rows.completionPoint,
              completionTotalPoint: res.rows.completionTotalPoint,

              multipleCount: res.rows.multipleCount,
              multiplePoint: res.rows.multiplePoint,
              multipleTotalPoint: res.rows.multipleTotalPoint,

              unsurenessCount: res.rows.unsurenessCount,
              unsurenessPoint: res.rows.unsurenessPoint,
              unsurenessTotalPoint: res.rows.unsurenessTotalPoint,

              singleCount: res.rows.singleCount,
              singlePoint: res.rows.singlePoint,
              singleTotalPoint: res.rows.singleTotalPoint,

              qualifiedPoint: res.rows.qualifiedPoint,
              totalPoint: res.rows.totalPoint,

            }

            sessionStorage.setItem("examPaper", JSON.stringify(examPaper))
            // console.log(JSON.stringify(res))

            var examSave = sessionStorage.getItem("examPaper")
            if (examSave != null) {
              this.$router.push({ name: 'examGoing', query: { id: this.$route.query.id, } })
            }
          }

        }

      })
    },

    topList: function () {
      this.$router.push({ name: 'topList', query: { id: this.$route.query.id, } })
    },

    recordList: function () {
      this.$router.push({ name: 'recordList', query: { id: this.$route.query.id, } })
    },




  }

}
</script>